<template>
	<view>
		<view class="search_box">
			<image src="../../static/s1.png" class="goback" @click="gobackClick" mode="widthFix"></image>
			<text class="topicText">话题广场</text>
		</view>
		<!-- 搜索 -->
		<view class="search">
			<image src="../../static/x1.png" class="searchImg" mode=""></image>
			<input type="text" value="" placeholder="每天为生活拍张照" class="searchInp" />
		</view>

		<view class="content_two" v-for="(content,index) in ConversationList" :key="index">
			<image :src= "imgurl + content.cover_image" class="nameImg" mode="aspectFill"></image>
			<view class="contentPray">
				<view class="contentPray_one">
					<view class="contentPray_one_left">
						<text>{{content.title}}</text>
						<image src="../../static/c2.png" class="reImg" mode="widthFix" v-if="content.is_hot == 1"></image>
					</view>
					<image src="../../static/addJoin.png" mode="" class="addJoin"></image>
				</view>
				<text class="contenText">{{content.content}}</text>
				<view class="contentPicture" >
					<view class="" v-for="(item,index) in content.images" :key = index>
						<image :src="imgurl + item" class="picImg" mode="aspectFill" @click="picClcik(index)"></image>
					</view>
					
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
				ConversationList: [],
				imgurl:'http://www.qifu2.com/'
			}
		},
		onShow() {
			this.getconversationList()
		},
		
		
		methods: {
			//返回社区
			gobackClick() {
				uni.navigateTo({
					url: '../community/community'
				})
			},
			// 获取话题列表
			async getconversationList(){
				let that = this
				const res = await that.$myRequest({
					url: 'index/getTopic',
					method: "POST",
					header: {
						'token':  '46d9d041eef41fd36d4bd1ebd1a12f89 '
					},
					data: {
						
					}
					
				})
			
				if(res.data.code == 1) {
					this.ConversationList = res.data.data.data
					console.log(this.ConversationList)
				} else {
					uni.showToast({
						title: res.data.msg,
						icon: 'none'
					})
				}
				
				
			},
			
			
			addFlagClick(id) {
				let that = this;
				var content_list = that.contentList;
				console.log(id);
				for (var i = 0; i < content_list.length; i++) {
					if (content_list[i].id == id) {
						content_list[i].name = !content_list[i].name;
					}
				}


				// this.contentList.forEach((item)=>{
				// 	console.log(item.id)


				// })
			}

		}
	}
</script>

<style lang="scss">
	.goback {
		width: 22rpx;
		margin: 0 0rpx 0 28rpx;
	}

	.topicText {
		font-size: 35rpx;
		color: #FFFFFF;
		margin: 0 auto;
		letter-spacing: 2rpx;
		font-weight: 700;
	}

	.search {
		display: flex;
		align-items: center;
		width: 93%;
		background-color: #EEE7E7;
		height: 69rpx;
		border-radius: 40rpx;
		margin: 20rpx auto 40rpx;
		box-sizing: border-box;

		.searchImg {
			width: 49rpx;
			height: 43rpx;
			margin-left: 20rpx;
		}

		.searchInp {
			font-size: 30rpx;
			color: #ABABAB;
			padding-left: 10rpx;
		}

	}

	.content_two {
		display: flex;
		width: 100%;
		padding-left: 30rpx;
		padding-top: 15rpx;
	
		.nameImg {
			width: 80rpx;
			height: 80rpx;
		}
	
		.contentPray {
			display: flex;
			flex-direction: column;
			width: 100%;
			padding-left: 10rpx;
	
			.contentPray_one {
				display: flex;
				justify-content: space-between;
	
				.contentPray_one_left {
					display: flex;
					font-size: 24rpx;
					color: #333333;
	
					.reImg {
						width: 33rpx;
						margin-left: 10rpx;
					}
				}
	
				.addJoin {
					// width: 66rpx;
					width: 66rpx;
					height: 30rpx;
					padding-right: 50rpx;
				}
			}
	
			.contenText {
				font-size: 21rpx;
				width: 100%;
				color: #333333;
				padding: 10rpx 0 0;
				overflow: hidden;
				-webkit-line-clamp: 1;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
			}
	
			.contentPicture {
				display: flex;
				
				flex-wrap: wrap;
				
				// width: 100%;
				padding: 10rpx 0;
				// margin: 20rpx 0;
	
				.picImg {
					width: 160rpx;
					height: 200rpx;
					margin: 5rpx;
				}
			}
		}
	}
</style>
